<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<div id=PageSelectorBar>
    <div id=PageSelectorMemo>
        页次：${pageBean.currentPage }/${pageBean.pageCount }页 &nbsp;
        每页显示：${pageBean.pageSize}
        <select id="pages" onblur="gotoPageNum(1,this.value,'${url}')">
            <c:if test="${pageBean.pageSize == 2}">
                <option value='2' selected="selected">2</option>
                <option value='5'>5</option>
                <option value='10'>10</option>
            </c:if>
            <c:if test="${pageBean.pageSize==5}">
                <option value="2">2</option>
                <option value="5" selected>5</option>
                <option value="10">10</option>
            </c:if>
            <c:if test="${pageBean.pageSize==10}">
                <option value='2'>2</option>
                <option value='5'>5</option>
                <option value='10' selected="selected">10</option>
            </c:if>
        </select> 条&nbsp;
        总记录数：${pageBean.recordCount }
    </div>
    <div id=PageSelectorSelectorArea>
        <a href="#" onclick="gotoPageNum(1,${pageBean.pageSize},'${url}')" title="首页" style="cursor: hand;">
            <img src="${pageContext.request.contextPath}/style/blue/images/pageSelector/firstPage.png"/>
        </a>

        <c:forEach begin="${pageBean.beginPageIndex}" end="${pageBean.endPageIndex}" varStatus="s">
            <c:if test="${pageBean.currentPage == s.count}">
                <span class="PageSelectorNum PageSelectorSelected">${s.count}</span>
            </c:if>
            <c:if test="${pageBean.currentPage != s.count}">
                <%--						<span class="PageSelectorNum" style="cursor: pointer;" onClick='gotoPageNum(${s.count});'>--%>
                <span class="PageSelectorNum" style="cursor: pointer;"
                      onClick="gotoPageNum(${s.count},${pageBean.pageSize},'${url}')">
                        ${s.count}
                </span>
            </c:if>
        </c:forEach>

        <a href="#" onclick="gotoPageNum(${pageBean.pageCount},${pageBean.pageSize},'${url}')" title="尾页"
           style="cursor: hand;">
            <img src="${pageContext.request.contextPath}/style/blue/images/pageSelector/lastPage.png"/>
        </a>

        转到：
        <select id="pages" onchange="gotoPageNum(this.value,${pageBean.pageSize},'${url}')">
            <c:forEach begin="1" end="${pageBean.endPageIndex}" varStatus="s">
                <option value='${s.count}'>
                        ${s.count}
                </option>
            </c:forEach>
        </select>
        <script type="text/javascript">
            $("#pages").val(${pageBean.currentPage});
        </script>
    </div>
</div>

<script type="text/javascript">
    function gotoPageNum(currentPage, pageSize, url) {
        //动态添加一个隐藏输入框，传递页码
        //$("#pageForm").append('<input id="currentPage" type="hidden" value="' + currentPage + '" name="currentPage"/>');
       // $("#pageForm").submit();
        //拼接地址
        console.log(currentPage)
        if (url != null) {
            var listUrl = "${pageContext.request.contextPath}" + url;
            if (currentPage != null && currentPage !== "") {
                listUrl += "&currentPage=" + currentPage + "&"
            }
            if (pageSize != null && pageSize !== "") {
                listUrl += "pageSize=" + pageSize;
            }
        }
        console.log(listUrl)
        window.location = listUrl;
    }
</script>
